
/* THIS CODE GENERATED FROM DATA AVAILABLE AT http://www.sil.org/iso639-3/download.asp */
	
/* Copyright 2010 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT c;pWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 /*
 * @author Jeremy Brown
 */
 
package org.sil.iso639_3;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class LanguagesByMacrolanguage
{
	static Map<String,String[]> codeMap = new HashMap<String,String[]>();
	
	public static Map<String,String[]> getCodeMap()
	{
		return codeMap;
	}
	
	public static String[] getCodes(String macrolanguageCode)
	{
		if(macrolanguageCode == null){return null;}
		macrolanguageCode = macrolanguageCode.trim();
		if(macrolanguageCode.equals("")){return null;}
		macrolanguageCode = macrolanguageCode.toLowerCase();
		if(! (macrolanguageCode.matches("^[a-z]{3,3}"))){return null;}
		return (String[])(codeMap.get(macrolanguageCode));
	}
	
	//getAt() allows for Groovy notation: LanguagesByMacrolanguage["ara"]
	public static LD[] getAt(String macrolanguageCode)
	{
		return LanguagesByMacrolanguage.get(macrolanguageCode);
	}
	
	public static LD[] get(String macrolanguageCode)
	{
		String[] langCodes = LanguagesByMacrolanguage.getCodes(macrolanguageCode);
		if(langCodes == null){return null;}
		LD[] langs = new LD[langCodes.length];
		int i = 0;
		for(String code : langCodes)
		{
			langs[i] = LanguageByCode.get(code);
			i++;
		}
		return langs;
	}
	
	private static void $(String macrolanguageCode, String[] languageCodes)
	{
		codeMap.put(macrolanguageCode, languageCodes);
	}
	
	static
	{
		$("aka", new String[]{"fat","twi"});
		$("ara", new String[]{"aao","abh","abv","acm","acq","acw","acx","acy","adf","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","shu","ssh"});
		$("aym", new String[]{"ayc","ayr"});
		$("aze", new String[]{"azb","azj"});
		$("bal", new String[]{"bcc","bgn","bgp"});
		$("bik", new String[]{"bcl","bln","bto","cts","fbl","lbl","rbl","ubl"});
		$("bnc", new String[]{"ebk","lbk","obk","rbk","vbk"});
		$("bua", new String[]{"bxm","bxr","bxu"});
		$("chm", new String[]{"mhr","mrj"});
		$("cre", new String[]{"crj","crk","crl","crm","csw","cwd"});
		$("del", new String[]{"umu","unm"});
		$("den", new String[]{"scs","xsl"});
		$("din", new String[]{"dib","dik","dip","diw","dks"});
		$("doi", new String[]{"dgo","xnr"});
		$("est", new String[]{"ekk","vro"});
		$("fas", new String[]{"pes","prs"});
		$("ful", new String[]{"ffm","fub","fuc","fue","fuf","fuh","fui","fuq","fuv"});
		$("gba", new String[]{"bdt","gbp","gbq","gmm","gso","gya"});
		$("gon", new String[]{"ggo","gno"});
		$("grb", new String[]{"gbo","gec","grj","grv","gry"});
		$("grn", new String[]{"gnw","gug","gui","gun","nhd"});
		$("hai", new String[]{"hax","hdn"});
		$("hbs", new String[]{"bos","hrv","srp"});
		$("hmn", new String[]{"cqd","hea","hma","hmc","hmd","hme","hmg","hmh","hmi","hmj","hml","hmm","hmp","hmq","hms","hmw","hmy","hmz","hnj","hrm","huj","mmr","muq","mww","sfm"});
		$("iku", new String[]{"ike","ikt"});
		$("ipk", new String[]{"esi","esk"});
		$("jrb", new String[]{"ajt","aju","jye","yhd","yud"});
		$("kau", new String[]{"kby","knc","krt"});
		$("kln", new String[]{"enb","eyo","niq","oki","pko","sgc","spy","tec","tuy"});
		$("kok", new String[]{"gom","knn"});
		$("kom", new String[]{"koi","kpv"});
		$("kon", new String[]{"kng","kwy","ldi"});
		$("kpe", new String[]{"gkp","xpe"});
		$("kur", new String[]{"ckb","kmr","sdh"});
		$("lah", new String[]{"hnd","hno","jat","phr","pmu","pnb","skr","xhe"});
		$("lav", new String[]{"ltg","lvs"});
		$("luy", new String[]{"bxk","ida","lkb","lko","lks","lri","lrm","lsm","lto","lts","lwg","nle","nyd","rag"});
		$("man", new String[]{"emk","mku","mlq","mnk","msc","mwk","myq"});
		$("mlg", new String[]{"bhr","bjq","bmm","msh","plt","skg","tdx","txy","xmv","xmw"});
		$("mon", new String[]{"khk","mvf"});
		$("msa", new String[]{"bjn","btj","bve","bvu","coa","dup","hji","ind","jak","jax","kvb","kvr","kxd","lce","lcf","liw","max","meo","mfa","mfb","min","mqg","msi","mui","orn","ors","pel","pse","tmw","urk","vkk","vkt","xmm","zlm","zmi","zsm"});
		$("mwr", new String[]{"dhd","mtr","mve","rwr","swv","wry"});
		$("nor", new String[]{"nno","nob"});
		$("oji", new String[]{"ciw","ojb","ojc","ojg","ojs","ojw","otw"});
		$("orm", new String[]{"gax","gaz","hae","orc"});
		$("pus", new String[]{"pbt","pbu","pst"});
		$("que", new String[]{"cqu","qub","qud","quf","qug","quh","quk","qul","qup","qur","qus","quw","qux","quy","quz","qva","qvc","qve","qvh","qvi","qvj","qvl","qvm","qvn","qvo","qvp","qvs","qvw","qvz","qwa","qwc","qwh","qws","qxa","qxc","qxh","qxl","qxn","qxo","qxp","qxr","qxt","qxu","qxw"});
		$("raj", new String[]{"bgq","gda","gju","hoj","mup","wbr"});
		$("rom", new String[]{"rmc","rmf","rml","rmn","rmo","rmw","rmy"});
		$("sqi", new String[]{"aae","aat","aln","als"});
		$("srd", new String[]{"sdc","sdn","src","sro"});
		$("swa", new String[]{"swc","swh"});
		$("syr", new String[]{"aii","cld"});
		$("tmh", new String[]{"taq","thv","thz","ttq"});
		$("uzb", new String[]{"uzn","uzs"});
		$("yid", new String[]{"ydd","yih"});
		$("zap", new String[]{"zaa","zab","zac","zad","zae","zaf","zai","zam","zao","zaq","zar","zas","zat","zav","zaw","zax","zca","zoo","zpa","zpb","zpc","zpd","zpe","zpf","zpg","zph","zpi","zpj","zpk","zpl","zpm","zpn","zpo","zpp","zpq","zpr","zps","zpt","zpu","zpv","zpw","zpx","zpy","zpz","zsr","zte","ztg","ztl","ztm","ztn","ztp","ztq","zts","ztt","ztu","ztx","zty"});
		$("zha", new String[]{"zch","zeh","zgb","zgm","zgn","zhd","zhn","zlj","zln","zlq","zqe","zyb","zyg","zyj","zyn","zzj"});
		$("zho", new String[]{"cdo","cjy","cmn","cpx","czh","czo","gan","hak","hsn","lzh","mnp","nan","wuu","yue"});
		$("zza", new String[]{"diq","kiu"});

		codeMap = (Map<String,String[]>)Collections.unmodifiableMap(codeMap);
	}
}